package nc.tb.chartreport;

import java.awt.Color;

public class ChartColorCTL {
	/** A very dark red color. */
	public static final Color VERY_DARK_RED = new Color(0x80, 0x00, 0x00);

	/** A dark red color. */
	public static final Color DARK_RED = new Color(0xc0, 0x00, 0x00);

	/** A light red color. */
	public static final Color LIGHT_RED = new Color(0xFF, 0x40, 0x40);

	/** A very light red color. */
	public static final Color VERY_LIGHT_RED = new Color(0xFF, 0x80, 0x80);

	/** A very dark yellow color. */
	public static final Color VERY_DARK_YELLOW = new Color(0x80, 0x80, 0x00);

	/** A dark yellow color. */
	public static final Color DARK_YELLOW = new Color(0xC0, 0xC0, 0x00);

	/** A light yellow color. */
	public static final Color LIGHT_YELLOW = new Color(0xFF, 0xFF, 0x40);

	/** A very light yellow color. */
	public static final Color VERY_LIGHT_YELLOW = new Color(0xFF, 0xFF, 0x80);

	/** A very dark green color. */
	public static final Color VERY_DARK_GREEN = new Color(0x00, 0x80, 0x00);

	/** A dark green color. */
	public static final Color DARK_GREEN = new Color(0x00, 0xC0, 0x00);

	/** A light green color. */
	public static final Color LIGHT_GREEN = new Color(0x40, 0xFF, 0x40);

	/** A very light green color. */
	public static final Color VERY_LIGHT_GREEN = new Color(0x80, 0xFF, 0x80);

	/** A very dark cyan color. */
	public static final Color VERY_DARK_CYAN = new Color(0x00, 0x80, 0x80);

	/** A dark cyan color. */
	public static final Color DARK_CYAN = new Color(0x00, 0xC0, 0xC0);

	/** A light cyan color. */
	public static final Color LIGHT_CYAN = new Color(0x40, 0xFF, 0xFF);

	/** Aa very light cyan color. */
	public static final Color VERY_LIGHT_CYAN = new Color(0x80, 0xFF, 0xFF);

	/** A very dark blue color. */
	public static final Color VERY_DARK_BLUE = new Color(0x00, 0x00, 0x80);

	/** A dark blue color. */
	public static final Color DARK_BLUE = new Color(0x00, 0x00, 0xC0);

	/** A light blue color. */
	public static final Color LIGHT_BLUE = new Color(0x40, 0x40, 0xFF);

	/** A very light blue color. */
	public static final Color VERY_LIGHT_BLUE = new Color(0x80, 0x80, 0xFF);

	/** A very dark magenta/purple color. */
	public static final Color VERY_DARK_MAGENTA = new Color(0x80, 0x00, 0x80);

	/** A dark magenta color. */
	public static final Color DARK_MAGENTA = new Color(0xC0, 0x00, 0xC0);

	/** A light magenta color. */
	public static final Color LIGHT_MAGENTA = new Color(0xFF, 0x40, 0xFF);

	/** A very light magenta color. */
	public static final Color VERY_LIGHT_MAGENTA = new Color(0xFF, 0x80, 0xFF);

	public static int[] getDefaultColorRGBs() {
		return new int[] { Color.red.getRGB(), Color.blue.getRGB(),
				Color.green.getRGB(), Color.yellow.getRGB(),
				Color.orange.getRGB(), Color.magenta.getRGB(),
				Color.cyan.getRGB(), Color.pink.getRGB(), Color.gray.getRGB(),
				DARK_RED.getRGB(), DARK_BLUE.getRGB(), DARK_GREEN.getRGB(),
				DARK_YELLOW.getRGB(), DARK_MAGENTA.getRGB(),
				DARK_CYAN.getRGB(), Color.darkGray.getRGB(),
				LIGHT_RED.getRGB(), LIGHT_BLUE.getRGB(), LIGHT_GREEN.getRGB(),
				LIGHT_YELLOW.getRGB(), LIGHT_MAGENTA.getRGB(),
				LIGHT_CYAN.getRGB(), Color.lightGray.getRGB(),
				VERY_DARK_RED.getRGB(), VERY_DARK_BLUE.getRGB(),
				VERY_DARK_GREEN.getRGB(), VERY_DARK_YELLOW.getRGB(),
				VERY_DARK_MAGENTA.getRGB(), VERY_DARK_CYAN.getRGB(),
				VERY_LIGHT_RED.getRGB(), VERY_LIGHT_BLUE.getRGB(),
				VERY_LIGHT_GREEN.getRGB(), VERY_LIGHT_YELLOW.getRGB(),
				VERY_LIGHT_MAGENTA.getRGB(), VERY_LIGHT_CYAN.getRGB() };
	}

	/**
	 * 
	 * @return
	 */
	public static Color[] getDefaultColorArray() {
		return new Color[] { Color.red, Color.blue, Color.green, Color.yellow,
				Color.orange, Color.magenta, Color.cyan, Color.pink,
				Color.gray, DARK_RED, DARK_BLUE, DARK_GREEN, DARK_YELLOW,
				DARK_MAGENTA, DARK_CYAN, Color.darkGray, LIGHT_RED, LIGHT_BLUE,
				LIGHT_GREEN, LIGHT_YELLOW, LIGHT_MAGENTA, LIGHT_CYAN,
				Color.lightGray, VERY_DARK_RED, VERY_DARK_BLUE,
				VERY_DARK_GREEN, VERY_DARK_YELLOW, VERY_DARK_MAGENTA,
				VERY_DARK_CYAN, VERY_LIGHT_RED, VERY_LIGHT_BLUE,
				VERY_LIGHT_GREEN, VERY_LIGHT_YELLOW, VERY_LIGHT_MAGENTA,
				VERY_LIGHT_CYAN };
	}
	
	public static int getDefaultColor(int colorIndex) {
		Color[] c = ChartColorCTL.getDefaultColorArray();
		Color cc = colorIndex < c.length ? c[colorIndex] : c[colorIndex
				% c.length];
		return getColorHex(cc);
	}

	public static int getColorHex(Color color) {
		int colorHex = -1;
		if (color != null) {
			int iR = color.getRed();
			int iG = color.getGreen();
			int iB = color.getBlue();
			colorHex = iR * 256 * 256 + iG * 256 + iB;
		}
		return colorHex;
	}
}